package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.InoutProduct;
import com.dragon.repository.entity.WarehouseInout;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class WarehouseInoutVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "出入库单号")
    private String inoutCode;

    @ApiModelProperty(value = "出入库：1出库2入库")
    private Integer inoutType;

    @ApiModelProperty(value = "主表id")
    private Integer claimId;

    @ApiModelProperty(value = "仓库经手人id")
    private Integer responsibleId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date inoutTime;

    @ApiModelProperty(value = "仓库id")
    private Integer warehouseId;

    @ApiModelProperty(value = "类型：1领用2盘点3调拨4采购")
    private Integer type;

    @ApiModelProperty(value = "是否确认：0否1是")
    private Integer isPassed;

    @ApiModelProperty(value = "仓库名称")
    private String warehouseName;

    @ApiModelProperty(value = "领用物品出入list")
    private List<InoutProduct> inoutProductList;

    @ApiModelProperty(value = "领用人名称")
    private String userName;

    @ApiModelProperty(value = "部门名称")
    private String departmentName;

    @ApiModelProperty(value = "经办人名称")
    private String operatorName;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static WarehouseInout convert(WarehouseInoutVO vo) {
        WarehouseInout entity = new WarehouseInout();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<WarehouseInout> convertList(List<WarehouseInoutVO> list) {
        List<WarehouseInout> resultList = new ArrayList<>();
        for (WarehouseInoutVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
